<!DOCTYPE html>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="contextPath" value="${pageContext.request.contextPath}" />
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>审核管理员页面</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<meta content="width=device-width, initial-scale=1" name="viewport">
<link rel="stylesheet" type="text/css" href="${contextPath}/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="${contextPath}/css/bootstrap-theme.min.css" />
<link rel="stylesheet" type="text/css" href="${contextPath}/css/public.css">
<link rel="stylesheet" type="text/css" href="${contextPath}/css/jquery-ui.theme.min.css">
<link rel="stylesheet" type="text/css" href="${contextPath}/css/jquery-ui.min.css">
<script type="text/javascript" src="${contextPath}/js/jquery.min.js"></script>
<script type="text/javascript" src="${contextPath}/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${contextPath}/js/common.js"></script>
<script type="text/javascript" src="${contextPath}/js/jquery.ui.core.js"></script>
<script type="text/javascript" src="${contextPath}/js/jquery.ui.datepicker-ch.js"></script>
<script type="text/javascript" src="${contextPath}/js/jquery.ui.datepicker.js"></script>
<style type="text/css">
	#articleTop-tbody .titleTd, #articleList-tbody .titleTd{
		text-align: left;
	}
	#articleTop-tbody .titleTd a, #articleList-tbody .titleTd a{
		margin-left: 15px;
	}
</style>
</head>
<body>
	<jsp:include page="../head.jsp" />
	<!-------------------------------- 选项卡区域 -------------------------------------------------->
	<div class="container">
		<ul class="nav nav-tabs" role="tablist">
			<!-- <li class="active"><a href="#assignList" role="tab" data-toggle="tab">分配列表</a></li> 
			<li><a href="#inspectList" role="tab" data-toggle="tab">审核列表</a></li>-->
			<li class="active"><a href="#inspectByDayList" role="tab" data-toggle="tab">巡审列表</a></li>
			<li><a href="#quickInspection" role="tab" data-toggle="tab">快速审核</a></li>
			<li><a href="#errorType" role="tab" data-toggle="tab">错误类型</a></li>
			<li><a href="#modifyCompletedList" role="tab" data-toggle="tab">初审修改列表</a></li>
			<li ><a href="#articleList" role="tab" data-toggle="tab">交流区</a></li>
		</ul>
		<div class="tab-content">
	<!-- ****************************************分配列表******************************************************* 
			<div class="tab-pane active" id="assignList">
				<div class="panel panel-default">
					<div class="panel-body">
						<form class="form-inline" role="form">
							<div class="form-group">
								<div class="input-group">
									<div class="input-group-addon"> 用户名：</div>
									<input class="form-control" onkeydown="if(event.keyCode==13){return false;}" id="userNameCondition1" type="text" placeholder="查询用户">
								</div>
							</div>
							<div class="form-group">
								<p class="form-control-static">标注时间段：</p>
							</div>
							<div class="form-group">
								<select class="form-control" id="timeMark1">
									<option value="0">大于十分钟</option>
									<option value="1">小于十分钟</option>
								</select>
							</div>
							<div class="form-group" id="">
								<p class="form-control-static">审核人：</p>
							</div>
							<div class="form-group" id="inspectId-select" >
								<select class="form-control" name="inspectId" id="inspectId"></select>
							</div>
							<button type="button" id="search1Btn" class="btn btn-default">查询</button>
							<button type="button" id="assignBtn" class="btn btn-default">分配</button>
						</form>
					</div>
					<table class="table table-striped table-bordered">
						<thead>
							<tr>
								<th width='10%'>序号</th>
								<th width='15%'>别名</th>
								<th width='15%'>姓名</th>
								<th width='20%'>个数</th>	
								<th width='10%'><a href="#" id="choose"><span id="choose-p">全选</span></a></th>					
							</tr>
						</thead>
						<tbody id="assign-tbody"></tbody>
					</table>
					<ul class="pagination" id="assign-pagination"></ul>
				</div>
			</div>  -->
	<!-- ***********************************************审核列表*************************************************** 
			<div class="tab-pane active" id="inspectList">
				<div class="panel panel-default">
					<div class="panel-body">
						<form class="form-inline" role="form">
							<div class="form-group">
								<div class="input-group">
									<div class="input-group-addon"> 用户名：</div>
									<input class="form-control" onkeydown="if(event.keyCode==13){return false;}" id="userNameCondition" type="text" placeholder="查询用户">
								</div>
							</div>
							<button type="button" id="searchBtn" class="btn btn-default">查询</button>
							&nbsp;
							&nbsp;
							<div class="form-group">
								<p class="form-control-static">审核数量：</p>
							</div>
							<div class="form-group">
								<select class="form-control" id="inspectPercent_1">
									<option value="60">60%</option>
									<option value="70">70%</option>
									<option value="80">80%</option>
									<option value="90">90%</option>
									<option selected="selected"  value="100">100%</option>
								</select>
							</div>
						</form>
					</div>
					<table class="table table-striped table-bordered">
						<thead>
							<tr>
								<th width='10%'>序号</th>
								<th width='15%'>别名</th>
								<th width='15%'>姓名</th>
								<th width='20%'>个数</th>
								<th width='20%'>有效时间</th>
								<th width='20%'>剩余时间</th>					
							</tr>
						</thead>
						<tbody id="inspect-tbody"></tbody>
					</table>
					<ul class="pagination" id="inspectList-pagination"></ul>
				</div>
			</div>-->
	<!-- ***********************************************巡审列表(按天审核)*************************************************** -->
			<div class="tab-pane active" id="inspectByDayList">
				<div class="panel panel-default">
					<div class="panel-body">
						<form class="form-inline" role="form">
							<div class="form-group">
								<div class="input-group">
									<div class="input-group-addon"> 审核时间：</div>
									<input class="form-control" id="datepicker" value="" type="text" readonly="readonly">
								</div>
							</div>
							<button type="button" id="resetTime" class="btn btn-default">清空</button>
							<button type="button" id="search2Btn" class="btn btn-default">查询</button>
							&nbsp;
							&nbsp;
							&nbsp;
							&nbsp;
							<div class="form-group">
								<p class="form-control-static">审核数量：</p>
							</div>
							<div class="form-group">
								<select class="form-control" id="inspectPercent_2">
									<!-- <option value="10">10%</option>
									<option value="20">20%</option>
									<option value="30">30%</option> -->
									<option value="40">40%</option>
									<option value="50">50%</option>
									<option value="60">60%</option>
									<option value="70">70%</option>
									<option value="80">80%</option>
									<option value="90">90%</option>
									<option value="100">100%</option>
								</select>
							</div>
							<br/>
							<br/>
							<!-- <input style="cursor: pointer;" id="workGroupId_all" type="checkbox" value="all" class="workGroupCodes"/>
							<span style="cursor: pointer;" onclick="chooseCheckBox('all')">全部</span>&nbsp;&nbsp;&nbsp;&nbsp;
							<c:forEach items="${workGroupList }" var="p">
								<c:choose>  
								   	<c:when test="${p.paramValue eq '000004' }">    
								   		<input disabled="disabled" style="cursor: pointer;" id="workGroupId_${p.id }" type="checkbox" value="${p.paramValue }" class="workGroupCodes"/>
								   		<span style="cursor: pointer; text-decoration:line-through;">${p.paramName }</span>&nbsp;&nbsp;&nbsp;&nbsp;
								  	</c:when>  
								   	<c:otherwise>  
										<input style="cursor: pointer;" id="workGroupId_${p.id }" type="checkbox" value="${p.paramValue }" class="workGroupCodes"/>
										<span style="cursor: pointer;" onclick="chooseCheckBox('${p.id }')">${p.paramName }</span>&nbsp;&nbsp;&nbsp;&nbsp;
								   	</c:otherwise>  
								</c:choose>
							</c:forEach> -->
							<c:forEach items="${workGroupList }" var="p">
								<c:choose>  
								   	<c:when test="${p.paramValue eq '000004' }">    
								   		<input disabled="disabled" style="cursor: pointer;" id="workGroupId_${p.id }" type="radio" value="${p.paramValue }" name="workGroupRadio" class="workGroupCodes"/>
								   		<span style="cursor: pointer; text-decoration:line-through;">${p.paramName }</span>&nbsp;&nbsp;&nbsp;&nbsp;
								  	</c:when>  
								   	<c:otherwise>  
										<input style="cursor: pointer;" id="workGroupId_${p.id }" type="radio" value="${p.paramValue }" name="workGroupRadio" class="workGroupCodes"/>
										<span style="cursor: pointer;" onclick="chooseCheckBox('${p.id }')">${p.paramName }</span>&nbsp;&nbsp;&nbsp;&nbsp;
								   	</c:otherwise>  
								</c:choose>
							</c:forEach>
						</form>
					</div>
					<table class="table table-striped table-bordered">
						<thead>
							<tr>
								<th width='10%'>序号</th>
								<th width='15%'>日期</th>
								<th width='15%'>审核员</th>
								<th width='15%'>任务数</th>
								<th width='15%'>查询时间</th>
								<th width='20%'>状态</th>					
							</tr>
						</thead>
						<tbody id="inspectByDay-tbody"></tbody>
					</table>
					<ul class="pagination" id="inspectByDayList-pagination"></ul>
				</div>
			</div>
	<!-- ***********************************************快速审核*************************************************** -->
			<div class="tab-pane" id="quickInspection">
				<div class="panel panel-default">
					<div class="panel-body">
						<div align="center">
							<div class="alert alert-warning" align="center" style="width: 950px;">
								<p>
									注意：本功能只用于<span style="color:blue;">特殊审核</span>用途，如非<span style="color:red;">加急</span>任务请不要使用！谢谢！
								</p>
							</div>
						</div>
						<form class="form-inline" role="form">
							<div class="form-group">
								<div class="input-group">
									<div class="input-group-addon"> 用户名：</div>
									<input class="form-control" onkeydown="if(event.keyCode==13){return false;}" id="quickInspCondition" type="text" placeholder="查询包名">
								</div>
							</div>
							<button type="button" id="quickInspSearchBtn" class="btn btn-default">查询</button>
							&nbsp;
							&nbsp;
							&nbsp;
							&nbsp;
							<div class="form-group">
								<p class="form-control-static">审核数量：</p>
							</div>
							<div class="form-group">
								<select class="form-control" id="inspectPercent_3">
									<option value="10">10%</option>
									<option value="20">20%</option>
									<option value="30">30%</option>
									<option value="40">40%</option>
									<option value="50">50%</option>
									<option value="60">60%</option>
									<option value="70">70%</option>
									<option value="80">80%</option>
									<option value="90">90%</option>
									<option value="100">100%</option>
								</select>
							</div>
						</form>
					</div>
					<table class="table table-striped table-bordered">
						<thead>
							<tr>
								<th width='10%'>序号</th>
								<th width='15%'>包名</th>
								<th width='5%'>总数</th>
								<th width='15%'>剩余/无效/完成</th>
								<th width='15%'>有效时间</th>
								<th width='15%'>审核任务数(含无效任务)</th>				
							</tr>
						</thead>
						<tbody id="inspectByPackage-tbody"></tbody>
					</table>
					<ul class="pagination" id = "quickInspection-pagination"></ul>
				</div>
			</div>
		<!-- ***********************************************错误类型*************************************************** -->	
			<div class="tab-pane" id="errorType">
				<div class="panel panel-default">
					<div class="panel-body">
						<form class="form-inline" role="form">
							<div class="form-group">
								<div class="input-group">
									<div class="input-group-addon"> 错误类型：</div>
									<input class="form-control" onkeydown="if(event.keyCode==13){return false;}" id="errorTypeName" type="text" placeholder="添加错误类型">
								</div>
							</div>
							<button type="button" id="errorTyepAddBtn" class="btn btn-default">添加</button>
							&nbsp;&nbsp;
							<button type="button" id="reloadBtn" class="btn btn-default">刷新</button>
						</form>
					</div>
					<table class="table table-striped table-bordered">
						<thead>
							<tr>
								<th width='10%'>序号</th>
								<th width='60%'>错误类型</th>
								<th width='30%' colspan="2">操作</th>			
							</tr>
						</thead>
						<tbody id="errorType-tbody"></tbody>
					</table>
					<!-- <ul class="pagination" id="errorType-pagination"></ul> -->
				</div>
			</div>
			<!-- ***********************************************修改完成列表*************************************************** -->	
			<div class="tab-pane" id="modifyCompletedList">
				<div class="panel panel-default">
					<div class="panel-heading" style="height: 38px;">
						<span id="markTimeTotle" class="pull-right text-success" style="padding-left: 20px;"></span>
					</div>
					<div class="panel-body">
						<form class="form-inline" role="form">
							<div class="btn2" style="float: left;">
								<span style="color:green;">请注意，当可修改提交次数为1时，再次被退回的任务会被系统直接回收！</span>
								<br>
							</div>	
							<div style="float: right;">
								<div class="form-group">
									<p class="form-control-static">审核数量：</p>
								</div>
								<div class="form-group">
									<select class="form-control" id="inspectPercent_4">
										<!-- <option value="10">10%</option>
										<option value="20">20%</option>
										<option value="30">30%</option> -->
										<option value="40">40%</option>
										<option value="50">50%</option>
										<option value="60">60%</option>
										<option value="70">70%</option>
										<option value="80">80%</option>
										<option value="90">90%</option>
										<option value="100">100%</option>
									</select>
								</div>
								&nbsp;&nbsp;&nbsp;&nbsp;
								<div class="btn2" style="float: right;">
									<button type="button" id="modifyCompletedListSearchBtn" class="btn btn-default" >查询</button>
								</div>	
							</div>		
						</form>
						<div style="clear: both;"></div>
					</div>
					<table class="table table-striped table-bordered">
						<thead>
							<tr>
								<th width='4%'>序号</th>
								<th width='12%'>任务数</th>
								<th width='12%'>审核员</th>
								<th width='15%'>退回原因</th>
								<th width='15%'>可修改提交次数</th>
								<th width='15%'>修改完成时间</th>
							</tr>
						</thead>
						<tbody id = "modifyCompletedList-tbody"></tbody>
					</table>
					<ul class="pagination" id="modifyCompletedList-pagination"></ul>
				</div>
			</div>
			<!-- ----------------------------------------------文章列表--------------------------------------------------- -->
			<div class="tab-pane" id="articleList">
				<div class="panel panel-default">
					<div class="panel-heading" style="height: 38px;">	
						<!-- <span id="aduitingMarkTimeMonthTotle" class="pull-right text-success" style="padding-left: 20px;"></span>
						<span id="taskMarkTimeMonthTotle" class="pull-right text-success"></span> -->
					</div>
					<div class="panel-body">
						<form class="form-inline" role="form">			
							
							<div class="form-group">
								<div class="input-group" style="width: 300px;">
							    	<input class="form-control" onkeydown="if(event.keyCode==13){return false;}" id="articleTitle" type="text" placeholder="请输入要查询的文章标题">
							    	<span class="input-group-btn">
							    		<button type="button" id="searchForArticle" class="btn btn-default">查询</button>
							    	</span>
							    </div>
							</div>
							<div class="pull-right">
								<button type="button" id="articleOpenLogBtn" class="btn btn-info">浏览记录</button>
								<button type="button" id="checkUnreadMsgBtn" class="btn btn-default">查看回复 <span id="unreadMsgNumBadge" class="badge" style="background-color: #ce2323;font-weight: 100;"></span></button>
								<%	int x = 3; int y=2; 
									if(x<y){ //暂时用不上隐藏掉 %>
										<button type="button" id="ownedArticle" class="btn btn-warning">已发布文章</button>
										<button type="button" id="createArticle" class="btn btn-success">发表新文章</button>
								<%	} %>
							</div>
						</form>
						<div style="clear: both;"></div>
					</div>
					<table class="table table-striped table-bordered">
						<thead>
							<tr>
								<th colspan="6" style="text-align: left;">
									<span style="margin-left: 15px;">置顶&公告</span>
								</th>
							</tr>
							<tr>
								<th width='10%'>序号</th>
								<th width='50%'>标题</th>
								<th width='5%'>状态</th>
								<th width='10%'>作者</th>
								<th width='10%'>回复/浏览</th>
								<th width='15%'>发布时间</th>
							</tr>
						</thead>
						<tbody id = "articleTop-tbody">
						</tbody>
						<thead>
							<tr>
								<th colspan="6" style="text-align: left;">
									<span style="margin-left: 15px;">最新内容</span>
								</th>
							</tr>
						</thead>
						<tbody id = "articleList-tbody">
						</tbody>
					</table>
					<ul class="pagination"></ul>
				</div>
			</div>
		</div>
	</div>
	
	<!-------------------------------- 弹出窗口 -------------------------------------------------->
	<div id="errorTypeEditModal" class="modal fade" style="padding-top: 200px;">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
					<h4 class="modal-title">错误类型修改</h4>
				</div>
				<div class="modal-body">
					<form class="form" role="form">
						<div class="form-group" id="reTime">
							<div class="input-group">
								<span class="input-group-addon">修改错误类型：</span>
								<input class="form-control" onkeydown="if(event.keyCode==13){return false;}" id="errorTypeNameEdit" >
							</div>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" id="errorTypeEditSubmitBtn" class="btn btn-primary">提交</button>
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				</div>
			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
		<!--------------------------------  标注规则更新提示信息-------------------------------------------------->
	<div id="showVoiceNoteNotice" class="modal fade">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header" style="height: 50px;">
					<button type="button" class="close" data-dismiss="modal">
						<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
					</button>
				</div>
				<div class="modal-body" align="center" style="font-size: 18px;">
					<div>
						<span>标注说明有更新或新内容发布,请注意查看!</span>
						<br/>
						<a href="${contextPath}/security/voiceNote">点击查看</a>
						<br/>
						<br/>
						<span style="color:green; font-size: 14px;">如已了解更新内容可点击不再提示,本提示将会在下次内容更新之前不再弹出!</span>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" id="neverNotice" class="btn btn-success" >不再提示</button>
					<button type="button" id="noticeClose" class="btn btn-default" data-dismiss="modal">关闭</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal-dialog -->
	</div>
	<!--------------------------------  通知公告提示信息-------------------------------------------------->
	<div id="showNotice" class="modal fade">
		<div class="modal-dialog" style="width: 60%;">
			<div class="modal-content">
				<div class="modal-header" style="height: 50px;">
					<span id="noticeTitle" style="font-size: 22px"></span>
					<button type="button" class="close" data-dismiss="modal">
						<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
					</button>
				</div>
				<div class="modal-body" style="font-size: 18px;">
					<div>
						<div id="noticeContent"></div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" id="neverShow" class="btn btn-success" >不再提示</button>
					<button type="button" id="vtdNoticeClose" class="btn btn-default" data-dismiss="modal">关闭</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal-dialog -->
	</div>
	<script type="text/javascript">
		var nowPage = 0;
		var timeMark = 0;
		var userNameCondition = "";
		var pageTotal = 0;
		var dateCondition = "";
		var quickInspCondition = "";
		var errorTypeName = "";
//		var workGroupCodes = []; 
		var workGroupCode = "";
		var voiceNoteNoticeFlag = ${voiceNoteNoticeFlag };
		var searchTitle = "";
		$(document).ready(function(){
			//assignPage(1);   //改功能暂时取消
			//loadUserList(1); //审核管理不再提供初审功能
			//loadListByDay(1);   //考虑到效率问题刚进入页面不加载这个列表
			//loadQuickInspectionList(1);
			errorTypeList();   //错误类型列表 没有分页
			loadArticles(1);
			loadUnreadMsgNum();
			if(voiceNoteNoticeFlag==1){
				$("#showVoiceNoteNotice").modal('show');
			}
			/*--------------------------------------时间控件-------------------------------------------------------*/
			$("#datepicker").datepicker(); 
			$("#datepicker").datepicker('option', 'dateFormat','yy-mm-dd');//set dateFormat 
			/*--------------------------------------点击查询按钮-------------------------------------------------------*/
			$("#searchBtn").click(function(){
				timeMark = $("#timeMark").val();
				userNameCondition = $("#userNameCondition").val();
				loadUserList(1);
			});
			$("#search1Btn").click(function(){
				timeMark = $("#timeMark1").val();
				userNameCondition = $("#userNameCondition1").val();
				assignPage(1);
			});	
			
			$("#search2Btn").click(function(){
//				workGroupCodes = []; 
				workGroupCode = "";
				var checkedNum = $(".workGroupCodes:checked").length;
				if(checkedNum==0){
					alert("请选择一个工作组进行审核!");
					return false;
				}else{
					workGroupCode = $(".workGroupCodes:checked").val();
//					for(var i = 0; i<checkedNum; i++){
//						workGroupCodes.push($(".workGroupCodes:checked").eq(i).val());
//					}
				}
				dateCondition = $("#datepicker").val();
				loadListByDay(1);
			});
			$("#modifyCompletedListSearchBtn").click(function(){
				queryModifyCompletedList();
			});
			/*--------------------------------------时间重置按钮-------------------------------------------------------*/
			$("#resetTime").click(function(){
				$("#datepicker").val("");
			});
			$("#quickInspSearchBtn").click(function(){
				quickInspCondition = $("#quickInspCondition").val();
				if(quickInspCondition.length==0){
					alert("请输入查询条件!");
					return false;
				}
				loadQuickInspectionList(1);
			});
		});
		/*--------------------------------------全选-----------------------------------------------------------------*/
		$("#choose").click(function(){
			var choose = $("#choose-p").text();
			if(choose == "全选"){
				$(".checkbox1").prop("checked",true);
				$("#choose-p").text("取消");
			}else{
				$(".checkbox1").prop("checked",false);
				$("#choose-p").text("全选");
			}
		});
		/*----------------------------------------分配按钮---------------------------------------------------------*/	
		$("#assignBtn").click(function(){
			var checkList = $(".checkbox1");
			var l = checkList.length;
			var str="";
			for(var i=0;i<l;i++){
				if (checkList[i].checked == true) {
					var workerId = checkList[i].value;
					str = workerId +"/"+str;
        		}
			}
			var inspectorId = $("#inspectId").val();
			$.ajax({
				type:'POST',
				data:{"workerIds":str,"inspectorId":inspectorId},
				url:'${contextPath}/security/assignT',
				dataType:'json',
				success:function(data){
				if(data.replay == 1){
					alert("分配完成!!");
					assignPage(1);
				}
					
				}	
			});	
		});	//
		/*--------------------------------------分配页面-------------------------------------------------------*/
		assignPage = function(pageNum){
			$.ajax({
				type:'POST',
				data:{"inspectorId":0,"timeMark":timeMark,"page":pageNum,"userName":userNameCondition},
				url:'${contextPath}/security/inspectorManager',
				dataType:'json',
				success:function(data){
					$("#inspectId").empty();
					if(data.inspectorIds == ""){
						$("#inspectId").append("<option>无</option>");
					}else{
						$.each(data.inspectorIds,function(i,item){
							$("#inspectId").append("<option value="+item.inspectorId+">"+item.inspectorName+"</option>");
						});
					}
					$("#assign-tbody").empty();
					if(data.list == ""){
						$("#assign-tbody").empty();
						$("#assign-tbody").append("<tr class='text-danger'><td colspan='5'>无内容</td></tr>");
					}else{
						pageTotal = data.totlePage;
						$.each(data.list,function(i,item){
							//var status = "不可用";
							//if(item.userStatus == "1")status = "可用";
							$("#assign-tbody").append(
								"<tr>"+
									"<td>"+(i+1)+"</td>"+
									"<td>"+item.user_name+"</td>"+
									"<td>"+item.workerRealName+"</td>"+
									"<td>"+item.c+"</td>"+
									"<td><input type='checkbox' class='checkbox1' name='checkbox1' value='"+item.worker_id+"'/></td>"+
								"</tr>"
							);
							var pageDom = $(".pagination");
							pageDom.empty();
							page.creatPageHTML(pageNum,pageTotal,pageDom,"assignPage");
							/*--------------------------------------跳转页-------------------------------------------------------*/
							$(".pageGoBtn").click(function(){
								var pageNum = 0;
								pageNum = $(".pageGoText").val();
								if(pageNum !=0&&0<pageNum&&pageNum<pageTotal+1){
									loadUserList(pageNum);
								}
							});
						});
					}
				}
			});
		};
		/*--------------------------------------审核页面-------------------------------------------------------*/
		var intervalEveryOne = null;
		loadUserList = function(pageNum){
			timeMark = 999;  //去掉初审的时间选择条件  20161223
			$.ajax({
				type:'POST',
				data:{"timeMark":timeMark,"page":pageNum,"userName":userNameCondition},
				url:'${contextPath}/security/inspectorManager',
				dataType:'json',
				success:function(data){
					$("#inspect-tbody").empty();
					if(data.list == ""){
						$("#inspect-tbody").empty();
						$("#inspect-tbody").append("<tr class='text-danger'><td colspan='6'>无内容</td></tr>");
					}else{
						window.clearInterval(intervalEveryOne);
						pageTotal = data.totlePage;
						$.each(data.list,function(i,item){
							var status = "不可用";
							if(item.userStatus == "1")status = "可用";
							var overTimeHtml = "";
							if(item.inspTimeoutFlag){//如果已经超时直接显示超时
								overTimeHtml = "<span style='color:red'>已超时</span>";
							}else{
								overTimeHtml = "<span style='color:green' id = 'overTime_"+pageNum+"_"+(i + 1)+"'></span>";
								intervalEveryOne = window.setInterval(
									function() {
										ShowCountDown(item.endMsec,$("#overTime_"+pageNum+"_"+(i + 1)));
								}, 1000);
							}
							$("#inspect-tbody").append(
								"<tr>"+
									"<td>"+(i+1)+"</td>"+
									"<td><a target='_blank' href='${contextPath}/security/inspectorList?workerId="+item.worker_id+"&uploadUUID="+item.upload_uuid+"' onclick='addPercentParam(this,1);'>"+item.user_name+"</a></td>"+
									"<td>"+item.workerRealName+"</td>"+
									"<td>"+item.c+"</td>"+
									"<td>"+item.markTime+"</td>"+
									"<td>"+overTimeHtml+"</td>"+
								"</tr>"
							);
							var pageDom = $("#inspectList-pagination");
							pageDom.empty();
							page.creatPageHTML(pageNum,pageTotal,pageDom,"loadUserList");
							/*--------------------------------------跳转页-------------------------------------------------------*/
							$(".pageGoBtn").click(function(){
								var pageNum = 0;
								pageNum = $(".pageGoText").val();
								if(pageNum !=0&&0<pageNum&&pageNum<pageTotal+1){
									loadUserList(pageNum);
								}
							});
						});
					}
				}
			});
		};
		/*--------------------------------------巡审页面-------------------------------------------------------*/
		loadListByDay = function(pageNum){
			$.ajax({
				type:'POST',
				data:{"page":pageNum,"dateCondition":dateCondition,"workGroupCode":workGroupCode},
				url:'${contextPath}/security/inspectorByDay',
				dataType:'json',
				traditional:true,
				success:function(data){
					$("#inspectByDay-tbody").empty();
					if(data.list == ""){
						$("#inspectByDay-tbody").empty();
						$("#inspectByDay-tbody").append("<tr class='text-danger'><td colspan='6'>无内容</td></tr>");
					}else{
						pageTotal = data.totlePage;
						$.each(data.list,function(i,item){
							var insTbody = "";
							var status = "";
							var aLink = "";
							if(item.status==1||item.status==4){
								status = "<span style='color:green'>已审核</span>";
								aLink="<td><a target='_blank' href='javascript:void(0);'>"+item.wrDate+"</a></td>";
							}else if(item.status==3){
								status = "<span style='color:red'>未审核</span>";
								aLink="<td><a target='_blank' href='${contextPath}/security/inspectorByDayList?insDate="+item.wrDate+"&searchTime="+data.searchTime+"&workGroupCode="+data.workGroupCode+"&inspectorId="+item.inspectorId+"' onclick='addPercentParam(this,2);'>"+item.wrDate+"</a></td>";
							}
							insTbody ="<tr>"+
									"<td>"+(i+1)+"</td>";
							insTbody=insTbody+aLink;
							insTbody=insTbody+"<td>"+item.inspectorName+"</td>"+
									"<td>"+item.taskNum+"</td>"+
									"<td title='所审核的任务初审通过时间不会晚于此时间'>"+data.searchTime+"</td>"+
									"<td>"+status+"</td>"+
								"</tr>";
							$("#inspectByDay-tbody").append(insTbody);
							var pageDom = $("#inspectByDayList-pagination");
							pageDom.empty();
							page.creatPageHTML(pageNum,pageTotal,pageDom,"loadListByDay");
							/*--------------------------------------跳转页-------------------------------------------------------*/
							$(".pageGoBtn").click(function(){
								var pageNum = 0;
								pageNum = $(".pageGoText").val();
								if(pageNum !=0&&0<pageNum&&pageNum<pageTotal+1){
									loadListByDay(pageNum);
								}
							});
						});
					}
				}
			});
		};
		/*--------------------------------------快速审核-------------------------------------------------------*/
		loadQuickInspectionList = function(pageNum){   
			$.ajax({
				type:'POST',
				data:{"page":pageNum,"quickInspCondition":quickInspCondition},
				url:'${contextPath}/security/quickInspection',
				dataType:'json',
				success:function(data){
					$("#inspectByPackage-tbody").empty();
					if(data.list == ""){
						$("#inspectByPackage-tbody").empty();
						$("#inspectByPackage-tbody").append("<tr class='text-danger'><td colspan='6'>无内容</td></tr>");
					}else{
						pageTotal = data.totlePage;
						$.each(data.list,function(i,item){
							var invalid = item.invalid+item.wavZero;
							var remains = item.total - (item.finishTaskCount + invalid);
							var tr = "";
							if(item.markTime==0){
								tr = "<tr title='有效时间为0，点击包名可直接审核通过~!'>"+
									"<td>"+(i+1)+"</td>"+
									"<td><a style='color: green;' href='javascript:markTimeZero("+item.packId+");'>"+item.packName+"</a></td>"+
									"<td>"+item.total+"</td>"+
									"<td>"+remains+"/"+invalid+"/"+item.finishTaskCount+"</td>"+
									"<td style='color: green;'>"+item.markTime+"</td>"+
									"<td style='color: green;'>"+item.num+"</td>"+
								"</tr>";
							}else{
								tr = "<tr>"+
									"<td>"+(i+1)+"</td>"+
									"<td><a target='_blank' href='${contextPath}/security/quickInspectionList?packId="+item.packId+"&packName="+item.packName+"' onclick='addPercentParam(this,3);'>"+item.packName+"</a></td>"+
									"<td>"+item.total+"</td>"+
									"<td>"+remains+"/"+invalid+"/"+item.finishTaskCount+"</td>"+
									"<td>"+item.markTime+"</td>"+
									"<td>"+item.num+"</td>"+
								"</tr>";
							}
							$("#inspectByPackage-tbody").append(tr);
							var pageDom = $("#quickInspection-pagination");
							pageDom.empty();
							page.creatPageHTML(pageNum,pageTotal,pageDom,"loadQuickInspectionList");
							/*--------------------------------------跳转页-------------------------------------------------------*/
							$("#quickInspection .pageGoBtn").click(function(){
								var pageNum = 0;
								pageNum = $(".pageGoText").val();
								if(pageNum !=0&&0<pageNum&&pageNum<pageTotal+1){
									loadInspectPackageList(pageNum);
								}
							});
						});
					}
				}
			});
		};

		function markTimeZero(packId){
			var flag = confirm("该审核项目的有效时间为0，确定要审核通过吗？");
			if(flag){
				$.ajax({
					type : 'POST',
					data : {"packId" : packId},
					url : '${contextPath}/security/quickInspectionMarkTimeIsZero',
					dataType : 'json',
					success : function(data) {
						alert(data.message); 
						loadQuickInspectionList(1);
					}
				});
			}else{
			
			}
		}
		/*--------------------------------------公用方法-------------------------------------------------------*/
		addPercentParam = function(obj,idNo){ //处理链接地址键入百分比   idNo为页面两个select的id号
			var selectId = "inspectPercent_"+idNo;
			var href = obj.href.split("&percent")[0];//避免percent参数重复  链接截取掉percent之后的部分
			obj.href = href+"&percent="+$("#"+selectId).val();
		};
		/*--------------------------------------错误类型添加----------------------------------------------*/
		$("#reloadBtn").click(function(){
			errorTypeList();
		});
		$("#errorTyepAddBtn").click(function(){
			errorTypeName = $("#errorTypeName").val();
			if(errorTypeName.length==0){
				alert("请填写需要添加的错误类型!");
				return false;
			}
			var massage = "确定要添加 "+errorTypeName+" 到错误类型中吗?";
			var flag = confirm(massage);
			if(flag){
				$.ajax({
					type:'POST',
					data:{"errorTypeName":errorTypeName},
					url:'${contextPath}/security/checkErrorType',
					dataType:'json',
					success:function(data){
						if(data.message=='1'){
							addErrorType();
						}else{
							alert("该错误类型已经存在,请检查输入是否有误!");
						}
					}
				});
			}
		});
		addErrorType = function(){   
			$.ajax({
				type:'POST',
				data:{"errorTypeName":errorTypeName},
				url:'${contextPath}/security/addErrorType',
				dataType:'json',
				success:function(data){
					alert(data.message); 
					errorTypeList();
				}
			});
		};
		errorTypeList = function(){   
			$.ajax({
				type:'POST',
				data:{},
				url:'${contextPath}/security/errorTypeList',
				dataType:'json',
				success:function(data){
					$("#errorType-tbody").empty();
					if(data.list == ""){
						$("#errorType-tbody").empty();
						$("#errorType-tbody").append("<tr class='text-danger'><td colspan='3'>无内容</td></tr>");
					}else{
						$.each(data.list,function(i,item){
							var active = "";
							var paramNameSpan = "";
							if(item.isActive){
								paramNameSpan = "<td><span style='color:green'>"+item.paramName+"</span></td>";
								active = "<a href='javascript:void(0);' onclick='changeActive("+item.id+")'>禁用</a>";
							}else{
								paramNameSpan = "<td><span style='color:red'>"+item.paramName+"&nbsp;&nbsp;(已禁用)</span></td>";
								active = "<a href='javascript:void(0);' onclick='changeActive("+item.id+")'>启用</a>";
							}	
							var tr = "";
							tr = "<tr>"+
								"<td>"+(i+1)+"</td>"+
								paramNameSpan+
								"<td>"+
									"<a href='javascript:void(0);' onclick='goEdit("+item.id+",\""+item.paramName+"\")'>编辑</a>"+
								"</td>"+
								"<td>"+
									active+
								"</td>"+
							"</tr>";
							$("#errorType-tbody").append(tr);
						});
					}
					if(data.notice!=""){//显示通知公告
						$("#noticeTitle").html(data.notice.noticeTitle);
						$("#noticeContent").html(data.notice.noticeContent);
						$("#showNotice").modal('show');
					}
				}
			});
		};
		var oldName;
		var editId;
		function goEdit(id,oldErrorTypeName){
			oldName = oldErrorTypeName;
			editId = id;
			$("#errorTypeNameEdit").val(oldErrorTypeName);
			$("#errorTypeEditModal").modal('show');
		}
		$("#errorTypeEditSubmitBtn").click(function(){
			var errorTypeNameEdit = $("#errorTypeNameEdit").val();
			if(errorTypeNameEdit.length==0){
				alert("请填写需要修改的错误类型!");
				return false;
			}
			var massage = "确定要将 "+oldName+" 修改为  "+errorTypeNameEdit+" 吗?";
			var flag = confirm(massage);
			if(flag){
				$.ajax({
					type:'POST',
					data:{"errorTypeName":errorTypeNameEdit},
					url:'${contextPath}/security/checkErrorType',
					dataType:'json',
					success:function(data){
						if(data.message=='1'){
							editErrorType(editId,errorTypeNameEdit);
						}else{
							alert("该错误类型已经存在,请检查输入是否有误!");
						}
					}
				});
			}
		});
		function editErrorType(id,errorTypeNameEdit){   
			$.ajax({
				type:'POST',
				data:{"paramId":id,"errorTypeName":errorTypeNameEdit},
				url:'${contextPath}/security/editErrorType',
				dataType:'json',
				success:function(data){
					alert(data.message);
					$("#errorTypeEditModal").modal('hide'); 
					errorTypeList();
				}
			});
		};
		function changeActive(id){
			$.ajax({
				type:'POST',
				data:{"errorTypeId":id},
				url:'${contextPath}/security/changeErrorTypeActive',
				dataType:'json',
				success:function(data){
					if(data.message=="1"){
						//alert("设置错误类型是否可用成功~!");
					}else{
						alert("设置错误类型是否可用失败,请联系系统维护人员~!");
					}
					errorTypeList();
				}
			});
		}
		/*******************************倒计时**************************************************/
		function ShowCountDown(endTime, obj) {
			var now = new Date();
			var leftTime = endTime - now.valueOf();
			var leftsecond = parseInt(leftTime / 1000);
			var day1 = Math.floor(leftsecond / (60 * 60 * 24));
			var hour = Math.floor((leftsecond - day1 * 24 * 60 * 60) / 3600);
			var minute = Math
					.floor((leftsecond - day1 * 24 * 60 * 60 - hour * 3600) / 60);
			var second = Math.floor(leftsecond - day1 * 24 * 60 * 60 - hour
					* 3600 - minute * 60);

			obj.text(day1 + "天" + hour + "小时" + minute + "分" + second + "秒");
		}
		/*******************************巡审页面选择checkbox用**************************************************/
		function chooseCheckBox(tempId){
			var id = "#workGroupId_"+tempId;
			$(id).trigger("click");
		}
		/***********************************初审修改完成列表查询*********************************************/
		queryModifyCompletedList= function(){   
			$.ajax({
				type:'POST',
				url:'${contextPath}/security/queryModifyCompletedList',
				dataType:'json',
				success:function(data){
					$("#modifyCompletedList-tbody").empty();			
					if(data.list == ""){
						$("#modifyCompletedList-tbody").empty();
						$("#modifyCompletedList-tbody").append("<tr class='text-danger'><td colspan='6'>无内容</td></tr>");
					}else{
						$.each(data.list,function(i,item){
							$("#modifyCompletedList-tbody").append(
							"<tr>"+
								"<td>"+(i + 1)+"</td>"+
								"<td><a target='_blank' href='${contextPath}/security/modifyCompletedInspectorList?sendbackUUID="+item.sendbackUUID+"&inspectorId="+item.inspectorId+"&inspectorRecordId="+item.inspectorRecordId+"&workGroupCode="+item.workGroupCode+"' onclick='addPercentParam(this,4);'>"+item.num+"</a></td>"+
								"<td>"+item.inspectorName+"</td>"+
								"<td>"+item.reason+"</td>"+
								"<td>"+item.ableModifyCount+"</td>"+
								"<td>"+item.modifyCompletedTime+"</td>"+
							"</tr>"
							);		
						});
					}
				}
			});
		};
		$("#neverNotice").click(function(){
			$.ajax({
				type : 'POST',
				url : '${contextPath}/security/voiceNoteNoticeNeverReceive',
				success : function(data) {
					if(data.replay==0){
						alert("更新出错请联系系统维护人员！");
					}
				}
			});
			$("#noticeClose").trigger("click");
		});
		$("#neverShow").click(function(){
			$.ajax({
				type : 'POST',
				url : '${contextPath}/security/noticeNeverReceive',
				success : function(data) {
					if(data.replay==0){
						alert("更新出错请联系系统维护人员！");
					}
				}
			});
			$("#vtdNoticeClose").trigger("click");
		});
		//---------------------------------交流区处理代码----------------------------------------------
		$("#createArticle").click(function(){
			window.open("${contextPath}/security/createArticle","_blank");
		});
		$("#ownedArticle").click(function(){
			window.open("${contextPath}/security/ownedArticleList","_blank");
		});
		
		$("#searchForArticle").click(function(){
			searchTitle = $("#articleTitle").val();
			loadArticles(1);
		});
		
		loadArticles = function(pageNum){
			$.ajax({
				type: 'POST',
				url: '${contextPath}/security/loadArticles',
				data: {"title": searchTitle, "page": pageNum, "createUsername":""},
				dataType: 'json',
				success: function (data) { 
					if(data.topArticleList == ""){
						$("#articleTop-tbody").empty();
						$("#articleTop-tbody").append("<tr class='text-danger'><td colspan='6'>无内容</td></tr>");
					}else{
						$("#articleTop-tbody").empty();
						$.each(data.topArticleList,function (i, item) {
							var isLockedTD_top = "";
							if(item.isLocked==1){
								isLockedTD_top = "<td><img title='该文章禁止评论' alt='该文章禁止评论' src='${contextPath}/images/folder_lock.gif'></td>" 
							}else{
								isLockedTD_top = "<td></td>" 
							}	
							$("#articleTop-tbody").append(
								"<tr>"+
									"<td>" + (i + 1) + "</td>" + 
									"<td class='titleTd'><a href='${contextPath}/security/showArticleContent?id=" + item.id + "' target='_blank'>" + item.articleTitle + "</a></td>" + 
									isLockedTD_top+ 
									"<td>" + item.createUsername + "</td>" + 
									"<td>"+item.commentNum+"/"+item.openLogNum+"</td>" + 
									"<td>" + item.createTime + "</td>" + 
								"</tr>"
							);
		
						});
					}
					if (data.list == "") {
						$("#articleList-tbody").empty();
						$("#articleList-tbody").append("<tr class='text-danger'><td colspan='6'>无内容</td></tr>");
						var pageDom = $("#articleList .pagination");
						pageDom.empty();
					} else {
						$("#articleList-tbody").empty();
						$.each(data.list,function (i, item) {
							var isLockedTD = "";
							if(item.isLocked==1){
								isLockedTD = "<td><img title='该文章禁止评论' alt='该文章禁止评论' src='${contextPath}/images/folder_lock.gif'></td>" 
							}else{
								isLockedTD = "<td></td>" 
							}
							$("#articleList-tbody").append(
								"<tr>"+
									"<td>" + (i + 1) + "</td>" + 
									"<td class='titleTd'><a href='${contextPath}/security/showArticleContent?id=" + item.id + "' target='_blank'>" + item.articleTitle + "</a></td>" + 
									isLockedTD+ 
									"<td>" + item.createUsername + "</td>" + 
									"<td>"+item.commentNum+"/"+item.openLogNum+"</td>" + 
									"<td>" + item.createTime + "</td>" + 
								"</tr>"
							);
		
						});
						var pageDom = $("#articleList .pagination");
						pageDom.empty();
						pucPageTotle = data.totlePage;
						page.creatPageHTML(pageNum, pucPageTotle, pageDom, "loadArticles");
						$("#articleList .pageGoBtn").click(function () {
							var pageNum = 0;
							pageNum = $("#articleList .pageGoText").val();
							if (pageNum != 0 && 0 < pageNum && pageNum < pucPageTotle + 1) {
								loadUnCompletePackList(pageNum);
							}
						});
					}
				}
			});
		};
		
		// 查询被回复的新消息个数    checkUnreadMsgBtn
		loadUnreadMsgNum = function(){
			$.ajax({
				type : 'POST',
				url : '${contextPath}/security/loadUnreadMsgNum',
				success : function(data) {
					$("#unreadMsgNumBadge").html(data.num);
				}
			});
		};
		
		$("#checkUnreadMsgBtn").click(function(){
			window.open("${contextPath}/security/jumpToUnreadMsgListPage","_blank");
		});
		
		$("#articleOpenLogBtn").click(function(){
			window.open("${contextPath}/security/jumpToArticleOpenLogListPage","_blank");
		});
	</script>
</body>
</html>
